#ifndef HTML_BUILDER_H
#define HTML_BUILDER_H

#include "Config.h"
#include <QMap>
#include <QString>
#include <QSize>

struct Live2dConfig
{
    QString javaScript;
    QSize windowSize;
};

class HtmlBuilder
{
private:
    static HtmlBuilder* instance;
    HtmlBuilder();
public:
    static HtmlBuilder* Instance()
    {
        if (instance == nullptr)
            instance = new HtmlBuilder();
        return instance;
    }
private:
    QMap<QString, Live2dConfig> configMap;
    QString htmlTemplate;
public:

    [[nodiscard]] inline QString GetHtml(const QString& modelName)
    {
        return configMap.contains(modelName) ? htmlTemplate.arg(configMap[modelName].javaScript) : htmlTemplate.arg(configMap[Config::Instance()->GetDefaultModel()].javaScript);
    }

    [[nodiscard]] inline QSize GetWindowSize(const QString& modelName)
    {
        return configMap.contains(modelName) ? configMap[modelName].windowSize : configMap[Config::Instance()->GetDefaultModel()].windowSize;
    }

};


#endif //HTML_BUILDER_H
